﻿using Artizan.Iot.Hub.Mqtt.Server;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using MQTTnet.AspNetCore;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;

namespace Artizan.Iot.Hub.Mqtt.AspNetCore
{
    [DependsOn(
        typeof(AbpAspNetCoreMvcModule),
        typeof(ArtizanIotHubMqttApplicationContractsModule)
    )]
    public class ArtizanIotHubMqttAspNetCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            ConfigureIotHubMqttServerHostHeartbeat(context);
        }
        private void ConfigureIotHubMqttServerHostHeartbeat(ServiceConfigurationContext context)
        {
            // 注册 IHttpClientFactory 和 HttpClient 到依赖注入容器中，并配置一些默认行为，例如处理超时、重试策略等
            context.Services.AddHttpClient(IotHubMqttAspNetCoreConsts.MqttServerHostHeartbeatHttpClientName);
        }
    }
}